#include <QtWidgets/QApplication>
#include <QtWidgets/QOpenGLWidget>
#include <QtGui/QOpenGLFunctions>

class MyGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
public:
	MyGLWidget(QWidget *parent):QOpenGLWidget(parent){}

protected:
	void initializeGL()
	{
		initializeOpenGLFunctions();
		glClearColor(0.8f, 0.8, 1.0, 1.0);
	}

	void resizeGL(int w, int h)
	{

	}

	void paintGL()
	{
		glClear(GL_COLOR_BUFFER_BIT);
	}
};

int main(int argc, char *argv[])
{
	QApplication a(argc, argv);

	MyGLWidget widget(NULL);
	QSurfaceFormat format;
	format.setDepthBufferSize(24);
	format.setStencilBufferSize(8);
	format.setVersion(3, 2);
	format.setProfile(QSurfaceFormat::CoreProfile);
	widget.setFormat(format); // must be called before the widget or its parent window gets shown

	widget.resize(800, 600);
	widget.show();

	return a.exec();
}
